
package com.kugou.game.sdk.observers;

import com.kugou.game.sdk.core.SDKControler;

import android.content.Context;
import android.net.Uri;

/**
 * 描述:短信数据库变化监听
 * 
 * @author ljc
 * @since 2014-3-25 下午3:37:12
 */
public class MessagesObserver extends BaseContentObserver {
    private static String TAG = MessagesObserver.class.getSimpleName();

    private static MessagesObserver observer;

    public MessagesObserver(Context context) {
        super(context);
    }

    @Override
    public void registerContentObserver() {
        mContext.getContentResolver().registerContentObserver(Uri.parse("content://mms-sms/"),
                true, observer);
    }

    public synchronized static MessagesObserver getObserver() {
        if (observer == null) {
            init(SDKControler.getContext());
        }
        return observer;
    }

    public static void init(Context context) {
        if (observer == null) {
            observer = new MessagesObserver(context);
            observer.setObserverDelayed(0);
            observer.registerContentObserver();
        }
    }

    @Override
    protected void onEveryChange() {
        super.onEveryChange();
    }

    @Override
    protected int getDbObserver() {
        return BaseContentObserver.MESSAGE_DB_OBSERVER;
    }

}
